<cfcomponent displayname="lib gateway" hint="">

	<cffunction name="init" access="public" returntype="libGateway" output="false" displayname="lib Constructor" hint="I initialize a lib.">
		<cfargument name="datasourceSettings" type="any" required="true" />
		
		<cfset variables.dsn = arguments.datasourceSettings.getConfigSetting("dsn") />
		<cfset variables.dbtype = arguments.datasourceSettings.getConfigSetting("dbtype") />

		<cfreturn this />
	</cffunction>

	<cffunction name="getAll" access="public" returntype="query" output="false" displayname="" hint="">

		<cfset var libSelect = 0 />
		<cfquery name="libSelect" datasource="#variables.dsn#">
			SELECT * 
			FROM	lib	
		</cfquery>

		<cfreturn libSelect/>
	</cffunction>
	
	<cffunction name="getByUserID" access="public" returntype="query" output="false" displayname="" hint="">
		<cfargument name="userID" type="string">
		<cfset var libSelect = 0 />
		
		<cfquery name="libSelect" datasource="#variables.dsn#">
			SELECT 	 lib.*
			FROM	lib	INNER JOIN 
					libAccess ON lib.libID = libAccess.libID
			WHERE	libAccess.userID = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.userid#">
		</cfquery>

		<cfreturn libSelect/>
	</cffunction>

</cfcomponent>